﻿{extend name="layout/main-block" /}
{block name="sub-wrapper"}
<!--内容容器-->
<section id="sub-wrapper" class="full-screen page-task">
    <div id="sub-content">
        <div id="sub-header">
            <div class="sub-title"><h3><i class="fa fa-tasks"></i>任务--任务管理</h3></div>
            <div class="sub-tools">
                <div id="searchTool">
                    <form class="form-inline" >
                        <input size="30" class="form-control" id="phname" placeholder="请输入任务名称进行检索" />
                        <a class="btn btn-primary" id="searchname"><i class="fa fa-search"></i>搜索</a>
                        <a class="btn btn-info" id="delSearch"><i class="fa fa-search"></i>清空搜索</a>
                    </form>
                </div>
            </div>
        </div>

        <div class="table-responsive data-table">
            <table class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th class="text-center" width="34px">
                        <input type="checkbox" class="checkboxes" id="selectAll"/>
                    </th>
                    <th>ID</th>
                    <th>任务名称</th>
                    <!--<th>任务类型</th>-->
                    <th>任务描述</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>奖励值</th>
                    <th>状态</th>
                    <th>参与人数</th>
                    <th>限制人数</th>
                    <th>上报内容</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="task" id="v" empty="$empty" }
                <tr>
                    <td class="text-center">
                        <input type="checkbox" class="checkboxes" name="checkbox[]"/>
                    </td>
                    <td>{$v.id}</td>
                    <td>{$v.tname}</td>
                   <!-- <td>{--$--v.yname}</td>-->
                    <td>{$v.tillustration}</td>
                    <td>{$v.begin_at}</td>
                    <td>{$v.end_at}</td>
                    <td>{$v.reward}</td>
                    {if condition = "$v.status eq '0'"}
                    <td>未结束</td>
                    {elseif condition = "$v.status eq '1'"}
                    <td>结束</td>
                    {/if}
                    <td>{$v.countid}</td>
                    <td>{$v.partake_limit}</td>
                    <td>{$v.content}</td>
                    <td>
                        <ul class="record-tool">
                            <li><a class="btn btn-info btn-sm viewRecord" data-name="{$v.id}">查看</a></li>
                            <li><a class="btn btn-warning btn-sm editRecord" data-name="{$v.id}">修改</a></li>
                            {if condition = "$v.lower_status eq ''"}
                             <li><a class="btn btn-success btn-sm lowerRecord" data-name="{$v.id}">下发</a></li>
                            {else}
                            <li><a class="btn btn-warning btn-sm " data-name="{$v.id}">已下发</a></li>
                            {/if}
                            {if condition = "$v.push_status eq '0'"}
                            <li><a class="btn btn-info btn-sm pushRecord" data-name="{$v.id}" ><!--hr--e--f="/admin/task/jpush?id={--$--v--.id}"-->推送</a></li>
                            {elseif condition = "$v.push_status eq '1'"}
                            <li><a class="btn btn-warning btn-sm " data-name="{$v.id}">已推送</a></li>
                            {/if}
                            <li>
                                <input class="taskswitch" data-taskid="{$v.id}" data-end_at="{$v.end_at}" data-size="small"  data-on-text="开" data-on-color="success" data-off-text="关" data-off-color="danger"  type="checkbox" {if condition = "$v.status eq '0'"} checked="checked" {/if} />
                            </li>
                            <li><a class="btn btn-danger btn-sm delRecord" data-name="{$v.id}">删除</a></li>
                        </ul>
                    </td>
                </tr>
                {/volist}
                </tbody>

                <tfoot>
                <tr>
                    <td colspan="3">
                        <ul class="record-tool">
                            <li><a class="btn btn-success btn-sm" id="addRecord"><i class="fa fa-plus"></i> 增加</a></li>
                            <li><a class="btn btn-danger btn-sm" id="batchDel"><i class="fa fa-minus"></i>  批量删除</a></li>
                        </ul>
                    </td>
                    <td colspan="4" class="">
                        {$page}
                        <!--<ul class="pagination">
                            <li>
                                <a href="#" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li class="active"><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">5</a></li>
                            <li>
                                <a href="#" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </ul>-->
                    </td>
                    <td colspan="3" class="text-center">
                        <div class="table-summary">
                            <div class="input-group">
                                <div class="input-group-addon">到第</div>
                                <input type="text" class="form-control" id="goto" placeholder="" style="width:40px;">
                                <div class="input-group-addon">页</div>
                                <span class="input-group-btn">
                                    <a class="btn btn-primary" data-currentPage="{$currentPage}" data-lastPage="{$lastPage}" id="gotoPage"><i class="fa fa-arrow-right"></i>确定</a>
                                </span>
                            </div>
                        </div>
                    </td>
                    <td colspan="2" class="text-center">
                        共<span id="total-record" class="text-success fa-2x"> {$count} </span>条记录
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</section>
{/block}

{block name="viewRecord"}

<!--编辑工具-->
<div id="viewRecord" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">ID:<span id="recordId"></span></h4>
            </div>
            <div class="modal-body">
                <div class="col-xs-12">
                    <form class="form-horizontal" name="editForm">
                        <div class="form-group">
                            <label for="name">任务名称</label>
                            <input type="text" class="form-control" id="name" name="name" >
                        </div>
                        <!--<div class="form-group">
                            <label for="task_type_id">任务类型</label>
                            <select name="task_type_id" id="task_type_id" class="form-control">
                                {--volist-- name="type" id="t" empty="--$--empty" }
                                <option value="{--$--t.id}">{--$--t.name}</option>
                                {/--volist--}
                            </select>
                        </div>-->
                        <div class="form-group">
                            <label for="illustration">任务描述</label>
                            <textarea style="resize:none;" class="form-control" id="illustration" name="illustration" >

                            </textarea>
                        </div>
                        <div class="form-group">
                            <label for="begin_at">开始时间</label>
                            <input type="text" class="form-control datetimepicker" id="begin_at" name="begin_at">
                        </div>
                        <div class="form-group">
                            <label for="end_at">结束时间</label>
                            <input type="text" class="form-control datetimepicker" id="end_at" name="end_at">
                        </div>
                        <div class="form-group">
                            <label for="reward">奖励值</label>
                            <input type="number" class="form-control" min="1" id="reward" name="reward" >
                        </div>
                        <div class="form-group">
                            <label for="reward">限制人数(0表示不限制人数)</label>
                            <input type="number" class="form-control" min="0" value="0" id="partake_limit" name="partake_limit" >
                        </div>
                        <!--<div class="form-group">
                            <label>状态</label>
                            <input type="radio" class="status s1" name="status"  value="1"> 进行
                            <input type="radio" class="status s0" name="status"  value="0"> 未进行
                        </div>-->
                        <div class="form-group">
                            <label for="content">上报内容</label>
                            <textarea style="resize:none;" class="form-control" id="content" name="content" >

                            </textarea>
                        </div>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="modal-footer">
                <a class="btn btn-warning" data-dismiss="modal"><i class="fa fa-times"></i>关闭</a>
            </div>
        </div>
    </div>
</div>
<!--编辑工具-->
{/block}

{block name="lowerRecord"}
<!--编辑工具-->
<div id="lowerRecord" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
            <div class="modal-body">
                <div class="col-xs-12">
                    <form class="form-horizontal" name="lowerForm">
                        <div class="form-group">
                            <label>立即下发</label>
                            <input type="radio" class="lower_status l1" name="lower_status"  value="1"> 是
                            <input type="radio" class="lower_status l0" name="lower_status"  value="0"> 否
                        </div>
                        <div class="form-group lower_at" style="display: none">
                            <label for="lower_at1">下发时间</label>
                            <input type="text" class="form-control datetimepicker" id="lower_at1" name="lower_at">
                        </div>
                        <div class="form-group region_id" style="display: none">
                            <label for="region_id">下发区域</label>
                            <select name="region_id" id="region_id" class="form-control">
                                {volist name="region" id="r" empty="$empty" }
                                <option value="{$r.id}">{$r.name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group device_group_id" style="display: none">
                            <label for="device_group_id">选择设备组</label>
                            <select name="device_group_id" id="device_group_id" class="form-control">
                                <option value="0">请选择设备组</option>
                                {volist name="devicegroup" id="g" empty="$empty" }
                                <option value="{$g.id}">{$g.name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group user" style="display: none">
                            <label>选择用户组/指定用户</label>
                            <input type="radio" class="user" name="user" value="1" > 用户组
                            <input type="radio" class="user" name="user" value="2"> 指定用户

                            <select name="user_group_id" id="user_group_id" class="form-control" style="display: none">
                                <option value="0">请选择用户组</option>
                                {volist name="usergroup" id="ug" empty="$empty" }
                                <option value="{$ug.id}">{$ug.name}</option>
                                {/volist}
                            </select>
                            <select name="user_id" id="user_id" class="form-control" style="display: none">
                                <option value="0">请指定用户</option>
                                {volist name="user" id="u" empty="$empty" }
                                <option value="{$u.id}">{$u.username}</option>
                                {/volist}
                            </select>

                        </div>

                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="modal-footer">
                <a class="btn btn-warning" data-dismiss="modal"><i class="fa fa-times"></i>关闭</a>
            </div>
        </div>
    </div>
</div>
<!--编辑工具-->
{/block}



